<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE HTML>
<html>
	<head>
		<%@ include file="/WEB-INF/jsp/inc/taglibs.jsp"%>
		<%@ include file="/WEB-INF/jsp/inc/meta.jsp"%>
		<script type="text/javascript"
			src="${approot}/resource/jquery/validate/jquery.validate.js"></script>
		<link href="${approot}/resource/jquery/validate/jquery.validate.css"
			rel="stylesheet" type="text/css" />
		<link href="${approot}/resource/jquery/validate/style.css"
			rel="stylesheet" type="text/css" />
		<script type="text/javascript">
            /* <![CDATA[ */
            jQuery(function(){
            	
               
                jQuery('#excerpt').validated(function(){
					alert("通过验证");
					do_pay_money();
				});
            });
            /* ]]> */
        </script>

		<script type="text/javascript">
        function do_pay_money()
        {   
            var str=$('#excerpt').serializeObject();
            var jsons = $.toJSON(str);
            
            pay_money(jsons);
        }


        function pay_money(jsons){
        	var str;
        	var payWise;
            if(document.getElementById('payWise_1').checked == true){
            	str = '您确认以【现金缴费】的方式处理本次操作吗?';
            	payWise = 0;
            }else if(document.getElementById('payWise_2').checked == true){
            	str = '您确认以【气票缴费】的方式处理本次操作吗?';
            	payWise = 1;
            }else if(document.getElementById('payWise_3').checked == true){
            	str = '您确认以【卡扣费】的方式处理本次操作吗?';
            	payWise = 2;
            	if(document.getElementById('card_number').value==''){
            		alert('您选择了【卡扣费】方式缴费，卡号不能为空');
            		return false;
            	}
            	if(document.getElementById('residual_money').value < document.getElementById('gas_money').value){
            		alert('您当前账户余额不足，请充值。');
            		return false;
            	}
            }else{
            	alert('系统异常');
            	return false;
            }
            var excerptId = document.getElementById('excerpt_id').value;
            var cardId = document.getElementById('card_id').value;
            var cardNumber = document.getElementById('card_number').value;
        	if(confirm(str)){
        		$.ajax({
		 		   	url:'${approot}/admin/excerpt/pay_money/'+excerptId+'/'+cardId+'/'+cardNumber+'/'+payWise,
		 		   	dataType: 'json',
		 		   	contentType: 'application/json',
		 			data:null,
		 			type:'post',
		 			beforeSend:function(){
		 			  // $('#main').disabled='true';
		 			},
		 			error:function(request){
		 				alert(S);
		 			},
		 			success:function(data){
		 			   if(data.msg=="error")
		 			   {
		 	 			   alert('缴费失败');
		 			   }
		 			   if(data.msg=="succ")
		 			   {
		 				  alert('缴费成功');
		 				  window.location.reload();
		 			   }
		 			}
		 		   });
        	}
 	    
 	}
 	
 	function show_card_number(number){
 		$.ajax( {
			url : '${approot}/admin/excerpt/get_card_list/' + number,
			dataType : 'json',
			contentType : 'application/json',
			data : null,//$.toJSON({'id':id}),
			type : 'post',
			beforeSend : function() {
				// $('#main').disabled='true';
			},
			error : function(request) {
				//alert(S);
			},
			success : function(data) {
				if (data.msg == "error") {
					alert('系统异常，获取用户卡列表失败');
				}
				if (data.msg == "succ") {
				}
				var popUp = document.getElementById("popupcontent");
				popUp.style.left = "100px";
				popUp.style.width = 600 + "px";
				popUp.innerHTML = data.sb.toString();
				popUp.style.visibility = "visible";
				document.getElementById('show_card_list').style.display = 'block';

		}
		});
 	}
 	
 	function hidePopup(){
		var popUp = document.getElementById("popupcontent");
		popUp.style.visibility = "hidden";
		popUp.innerHTML = "";
	}
	
	function hidePopupOther(){
		document.getElementById('card_id').value = '';
 		document.getElementById('card_number').value = '';
 		document.getElementById('residual_money').value = '';
 		document.getElementById('show_card_list').style.display = 'none';
 		
		var popUp = document.getElementById("popupcontent");
		popUp.style.visibility = "hidden";
		popUp.innerHTML = "";
	}
	
	function set_card_number(cardId,cardNumber,residualMoney){
		document.getElementById('card_id').value = cardId;
		document.getElementById('card_number').value = cardNumber;
		document.getElementById('residual_money').value = residualMoney;
	}
	
	function addTask(){
		window.open("${approot}/admin/apply/apply_for_select/0","_blank","height=300,width=800,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,status=no,left=200,top=200");
	
	}
	
	function selected(a){
		var listTable = document.getElementById("web_tab").getElementsByTagName("tbody")[0];
		
		if(a != null && a.length > 0){
			for(var i = 0 ; i < a.length ; i++){
				var addTr = document.createElement("tr") ;
				var contents = a[i].split(",") ;
				for(var j = 1 ; j < contents.length ; j++){
					var addTd = document.createElement("td");
					addTd.appendChild(document.createTextNode(contents[j]));

					if(j == 1){
						var input = document.createElement("input");
						input.value = contents[0];
						input.type="hidden" ;
						input.name = "applyIds" ;
						addTd.appendChild(input);
					}

					addTr.appendChild(addTd);
				}
				
				var opTd = document.createElement("td");
				var delBar = document.createElement("a") ;
				delBar.innerHTML = "删除" ;
				delBar.href = "javascript:void(0)" ;
				delBar.onclick = function(e){
					delRow(e);
				}
				opTd.appendChild(delBar);
				addTr.appendChild(opTd);
				
				listTable.appendChild(addTr);				
			}
		}
	}
	function delRow(event){
		
		if(!event)event = window.event ;
		var target = event.srcElement||event.target ;
		
		var listTable = document.getElementById("web_tab").getElementsByTagName("tbody")[0];
		listTable.removeChild(target.parentNode.parentNode);
	}
        </script>

	</head>
	<body style="background: #E8F5FE; padding: 15px 18px;" class="scroll_r">
		<div id="right_w">
			<p>
				当前位置：报建管理 >> 任务单管理
			</p>
		</div>

		<form method="post" name="taskForm" action="${approot}/admin/apply/task_mod/${modType}" id="excerpt">
			<table border="0" cellpadding="0" cellspacing="1" width="92%"
				align="center" class="tab_l">
				<tr>
					<td>
						<b>请按要求填写：</b>
					</td>
					<td align="right">
						带<span style="color: #ff0000;">*</span>为必填
					</td>
				</tr>
			</table>
			<table border="0" cellpadding="0" cellspacing="1" width="92%"
				align="center" id="add_tab">
				<tr>
					<th width="20%">
						区域地址：
						<input type="hidden" name="taskId" value="${task.taskId}" id="taskId">
					</th>
					<td colspan="3">
						<input name="address" id="address" value="${task.address}"/>
						<span style="color: #ff0000; margin: 0;">*</span>
					</td>
				</tr>
				<tr>
					<th width="20%">
						经办人：
					</th>
					<td width="30%">
						<input id="jingbanUser" name="jingbanUser" value="${task.jingbanUser}"/>
						<span style="color: #ff0000; margin: 0;">*</span>
					</td>

					<th width="20%">
						下单时间：
					</th>
					<td width="30%">
						<input type="text" id="createDate" name="createDate"  value="${task.createDate}" class="Wdate" onFocus="WdatePicker({maxDate:'#F{$dp.$D(\'createDate\')}',startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true})"/>
					
						<span style="color: #ff0000; margin: 0;">*</span>
					</td>
				</tr>
				<tr>
					<th width="20%">
						安装要求：
					</th>
					<td colspan="3">
						<input id="requires" name="requires" value="${task.requires}"/>
						<span style="color: #ff0000; margin: 0;">*</span>
					</td>
				</tr>
				<tr>
					<th width="20%">
						完成时间及情况：
					</th>
					<td colspan="3">
						<input id="info" name="info" value="${task.info}"/>
						<span style="color: #ff0000; margin: 0;">*</span>
					</td>
				</tr>
				<tr>
					<th width="20%">
						业务受理人：
					</th>
					<td width="30%">
						<input id="yewuShouli" name="yewuShouli" value="${task.yewuShouli}"/>
						<span style="color: #ff0000; margin: 0;">*</span>
					</td>

					<th width="20%">
						施工受理人：
					</th>
					<td width="30%">
						<input id="shigongShouli" name="shigongShouli" value="${task.shigongShouli}"/>
						<span style="color: #ff0000; margin: 0;">*</span>
					</td>
				</tr>
			</table>
			<table border="0" cellpadding="0" cellspacing="1" width="92%"
				align="center" class="tab_l">
				<tr>
					<td>
						<b>任务列表：</b>
					</td>
					<td align="right">
						<input type="button" value="添加任务" onclick="addTask()">
					</td>
				</tr>
			</table>
			<table border="0" cellpadding="0" cellspacing="1" width="92%"
				align="center" id="web_tab">
				<tr>
					<th>用户类型</th>
					<th>申请人</th>
					<th>地址</th>
					<th>联系电话</th>
					<th>申请时间</th>
					<th>操作</th>
				</tr>
			<c:forEach var="apply" items="${applys}">
				<tr>
					<td>${apply.customTypeView}<input type="hidden" name="applyIds" value="${apply.applyId}"/></td>
					<td>${apply.customName}</td>
					<td>${apply.address}</td>
					<td>${apply.telNo}</td>
					<td>${apply.startDate}</td>
					<td><a href="javascript:void(0)" onclick="delRow(event)">删除</a></td>
				</tr>
			</c:forEach>
			</table>
			<p id="tab_but">
				<input type="button" value="确 定" onclick="document.taskForm.submit();">
			</p>
		</form>
	</body>
</html>
